package kr.co.doriclassic.pro08_01;

public class BankAccount {
	private int iBalance;
	public void deposit(int amount){
		iBalance+=amount;
	}
	public void  withDraw(int amount){
		if(iBalance>=amount||iBalance>0)
			iBalance-=amount;	
		else 
			System.out.println("잔액부족");
	}
	public int getBalence(){
		return iBalance;
	}	
	
	public void transfer(int amount, BankAccount otherAccount){
		if((iBalance<amount)||iBalance<0){
			System.out.println("잔액부족");
		}
		else{
			iBalance-=amount;
			System.out.println("당신의 계좌에서 "+amount+"원을차감했습니다.");
			otherAccount.iBalance+=amount;
			System.out.println("상대에게 "+amount+"원을 송금했습니다.");
		} 
	}
	@Override
	public String toString() {
		return iBalance+"";
	}	
}